<template>
  <ContentWrap>
    <el-descriptions :column="2" border>
      <el-descriptions-item label="申请人">
        {{ detailData.userName }}
      </el-descriptions-item>
      <el-descriptions-item label="申请主题">
        {{ detailData.applyTitle }}
      </el-descriptions-item>
      <el-descriptions-item label="盖章次数">
        {{ detailData.sealCount }}
      </el-descriptions-item>
      <el-descriptions-item label="印章类型">
        <dict-tag :type="DICT_TYPE.OA_SEAL_TYPE" :value="detailData.sealType ?? ''" />
      </el-descriptions-item>
      <el-descriptions-item label="用印部门">
        {{ detailData.deptId }}
      </el-descriptions-item>
      <el-descriptions-item label="用印部门">
        {{ detailData.deptName }}
      </el-descriptions-item>
      <el-descriptions-item label="预期用印日期" prop="expectedSealDate">
        {{ formatDate(detailData.expectedSealDate, 'YYYY-MM-DD') }}
      </el-descriptions-item>
      <el-descriptions-item label="印章是否外借" prop="isExternalBorrow">
        <dict-tag :type="DICT_TYPE.OA_IS_OR_NO" :value="detailData.isExternalBorrow ?? ''" />
      </el-descriptions-item>
      <el-descriptions-item label="印章借用日期" prop="borrowStartDate">
        {{ formatDate(detailData.borrowStartDate, 'YYYY-MM-DD') }}
      </el-descriptions-item>
      <el-descriptions-item label="结束借用日期" prop="borrowEndDate">
        {{ formatDate(detailData.borrowEndDate, 'YYYY-MM-DD') }}
      </el-descriptions-item>


      <el-descriptions-item label="审批结果">
        <dict-tag :type="DICT_TYPE.BPM_PROCESS_INSTANCE_STATUS" :value="detailData.status ?? ''" />
      </el-descriptions-item>
      <el-descriptions-item label="创建者">
        {{ detailData.creatorName }}
      </el-descriptions-item>


      <el-descriptions-item label="相关附件">
       <OaFileManager :header="false"  :initial-file-ids="detailData.files" />
      </el-descriptions-item>

    </el-descriptions>
    <el-descriptions :column="1" border>
      <el-descriptions-item label="盖章内容">
        {{detailData.sealContent}}
      </el-descriptions-item>
    </el-descriptions>
  </ContentWrap>
</template>
<script lang="ts" setup>
import { DICT_TYPE } from '@/utils/dict'
import { formatDate } from '@/utils/formatTime'
import { propTypes } from '@/utils/propTypes'
import { SealApplyApi, } from '@/api/oa/sealapply'

defineOptions({ name: 'oaSealApplyDetail' })

const { query } = useRoute() // 查询参数

const props = defineProps({
  id: propTypes.number.def(undefined)
})
const detailLoading = ref(false) // 表单的加载中
const detailData = ref<any>({}) // 详情数据
const queryId = query.id as unknown as number // 从 URL 传递过来的 id 编号

/** 获得数据 */
const getInfo = async () => {
  detailLoading.value = true
  try {
    detailData.value = await SealApplyApi.getSealApply(props.id || queryId)
  } finally {
    detailLoading.value = false
  }
}
defineExpose({ open: getInfo }) // 提供 open 方法，用于打开弹窗

/** 初始化 **/
onMounted(() => {
  getInfo()
})
</script>
